#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <unistd.h>

using namespace std;

class Student{
public:
    Student():num(0),age(0),name(nullptr){}
    Student(int num, int age,const char*name):num(num),age(age),name(new char[strlen(name)+1]){
        strcpy(this->name,name);
    }

    Student(const Student &rsh){
        num =rsh.num;
        age = rsh.age;
        name = new char[strlen(rsh.name)+1];
        strcpy(name,rsh.name);
        cout<<"------------copy-------------"<<endl;
    }
    
    Student &operator=(const Student &rsh){
        if(this != &rsh){
            if(name){
                delete [] name;
            }
            num =rsh.num;
            age = rsh.age;
            name = new char[strlen(rsh.name)+1];
            strcpy(name,rsh.name);
            cout<<"-----------assignment-----------"<<endl;
        }
        return *this;
    }
    ~Student(){
        if(name){
            delete [] name;
            name =nullptr;
        }
    }

    void Print(void) const{
        cout<<"name: "<<name<<", age: "<<age<<", number: "<<num<<endl;
    }


private:
    int num;
    int age;
    char *name;
};

Student test(){
    Student s(1,18,"ss");
    cout<<"test: "<<&s<<endl;
    return s;
}


int main()
{
    return 0;
}

